package org.androidannotations.gradle.view.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;
import org.androidannotations.gradle.view.model.DemoListItemVo;
import org.androidannotations.gradle.view.view.DemoListItemView;
import org.androidannotations.gradle.view.view.ViewBuilder;

@EBean
public class DemoListAdapter extends BaseListAdapter {

    @RootContext
    Context context;

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        DemoListItemView itemView;
        if (convertView == null) {
            itemView = ViewBuilder.buildDemoListItemView(context);
        } else {
            itemView = (DemoListItemView) convertView;
        }

        itemView.bind((DemoListItemVo) getItem(position));

        return itemView;
    }
}
